package com.yky.action.admin;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.aspose.words.Document;
import com.aspose.words.HeaderFooter;
import com.aspose.words.License;
import com.aspose.words.Paragraph;
import com.aspose.words.PdfSaveOptions;
import com.aspose.words.Section;
import com.aspose.words.Shape;
import com.aspose.words.ShapeType;
import com.yky.action.base.BaseActionSupport;
import com.yky.entity.Organization;
import com.yky.entity.OrganizationRecords;
import com.yky.entity.OrganizationRecordsAssumeProject;
import com.yky.entity.OrganizationRecordsCertificate;
import com.yky.entity.OrganizationRecordsCommittee;
import com.yky.entity.OrganizationRecordsInternalAudit;
import com.yky.entity.Province;
import com.yky.entity.User;
import com.yky.service.admin.OrganizationRecordsAssumeProjectService;
import com.yky.service.admin.OrganizationRecordsCertificateService;
import com.yky.service.admin.OrganizationRecordsCommitteeService;
import com.yky.service.admin.OrganizationRecordsInternalAuditService;
import com.yky.service.admin.OrganizationRecordsService;
import com.yky.service.admin.OrganizationService;
import com.yky.service.admin.ProvinceService;
import com.yky.service.admin.UserService;
import com.yky.utils.JsonUtil;
import com.yky.utils.ValidateUtils;
import com.yky.utils.base.DateUtils;

@ParentPackage("perInterceptor")
@InterceptorRefs( { @InterceptorRef("sessionStack") })
@Namespace(value = "/admin")
@Results( { @Result(name = "org_regsucess", type = "redirect", location = "/index/regSucess.jsp") })
public class OrgAction extends BaseActionSupport {

	private static final long serialVersionUID = 1L;

	@Autowired
	private OrganizationService organizationService;
	@Autowired
	private OrganizationRecordsService organizationRecordsService;
	@Resource
	private ProvinceService provinceService;
	@Resource
	private UserService userService;
	@Autowired
	private OrganizationRecordsCertificateService organizationRecordsCertificateService;
	@Autowired
	private OrganizationRecordsAssumeProjectService organizationRecordsAssumeProjectService;
	@Autowired
	private OrganizationRecordsCommitteeService organizationRecordsCommitteeService;
	@Autowired
	private OrganizationRecordsInternalAuditService organizationRecordsInternalAuditService;

	protected String id;
	private String pageIndex;
	private String pageShowCount;
	private String orgId;
	private Organization organization;

	private String name;
	private String organType;// ORGANTYPE
	private String organLevel;// ORGANLEVEL
	private String organCode;// ORGANCODE
	private String address;// ADDRESS
	private String postCode;// POSTCODE
	private String contactUser;// CONTACTUSER
	private String contactPhone;// CONTACTPHONE
	private String contactMobile;// CONTACTMOBILE
	private String contactEmail;// CONTACTEMAIL
	private String crTime;// CRTIME
	private String crUser;// CRUSER
	private String province;// province
	private String responsiblePerson;// RESPONSIBLEPERSON

	// 干细胞备案字段
	// 医疗机构执业许可证书复印件
	private String medicalInstitutionsExequaturPdf; // PDF
	private String medicalInstitutionsExequaturSubject; // 诊疗科目
	private String medicalInstitutionsExequaturStartDate; // 有效期（开始日期）
	private String medicalInstitutionsExequaturEndDate; // 有效期（结束日期）
	private String medicalInstitutionsExequaturRegisterNum; // 登记号

	// private String medicalClinicalTestCertificate;; // 药物临床试验机构资格认定证书复印件（PDF）

	private String organizationScheme; // 机构干细胞临床研究组织管理体系（框架图）和各部门职责（PDF）

	// 机构干细胞临床研究管理主要责任人
	private String researchManagementPrincipalPdf; // （PDF）
	private String researchManagementPrincipalResponsible; // 负责人

	// 机构干细胞临床研究质量受权人资质
	private String researchManagementAttorneyPdf; // （PDF）
	private String researchManagementAttorneyQualifiedPerson; // 质量受权人

	private String receiveTrainingPdf; // 相关人员接受培训资料
	private String academicAndEthicalPdf; // 机构学术委员会和伦理委员会资料
	private String workingSystemPdf; // 相应工作制度和标准操作规范
	private String preparationStandardPdf; // 干细胞制备标准操作规范
	private String studyQualityManagementDocumentPdf; // 干细胞临床研究质量管理文件
	private String auditSystemPdf; // 干细胞临床研究审计体系
	private String evaluationCriterionPdf; // 干细胞评价标准
	private String riskManagementMechanismPdf; // 预防干细胞临床研究风险管理机制
	private String treatmentMeasurePdf; // 预防干细胞临床研究风险处理不良反应、不良事件的措施

	private String pdf; // pdf
	private String certNumber; // 证书编号
	private String affirmationProfession; // 认定专业
	private String startDate; // 有效期（开始日期）
	private String endDate; // 有效期（结束日期）

	// 2015-10-27 12:25:58
	private String isSubmitPaperyMaterial; // 是否提交纸质材料

	// 2016-04-15 16:51:28 start xiaoan
	private String projectType; // 项目类型
	private String projectName; // 项目名称
	private String projectNumber; // 项目编号
	private String principal; // 负责人
	private String expenditure; // 经费（万）
	private String leaderUnit; // 牵头单位/参与单位
	private String participationUnit; // 参与单位名单

	private String memberName; // 成员名称
	private String duty;// 职务
	private String professional;// 职称
	private String specialty;// 专业
	private String unit; // 单位
	private Integer memberType; // 成员类型 1-主任 2-副主任
	private Integer committeeType; // 委员会类型 1-学术 2-伦理

	private String department; // 工作部门

	// 备案主表

	// 机构干细胞临床研究管理主要责任人
	private String researchManagementPrincipalDuty; // 职务
	private String researchManagementPrincipalProfessional; // 职称
	private String researchManagementPrincipalSpecialty; // 专业
	private String researchManagementPrincipalCertificatePdf; // 职务

	// 机构干细胞制剂质量受权人资质
	private String researchManagementAttorneyDuty; // 职务
	private String researchManagementAttorneyProfessional; // 职称
	private String researchManagementAttorneySpecialty; // 专业
	private String researchManagementAttorneyEducation; // 学历
	private String researchManagementAttorneyLimit; // 从事干细胞制剂（或相关产品）制备和质量管理年限
	private String researchManagementAttorneyExperiencePdf; // 从事相关产品过程控制和质量检验工作经历

	// 相关人员接受培训资料
	private String ethicalTrainingPdf; // 主要研究人员伦理培训证书

	// 机构学术委员会
	private String academicPdf; // pdf资料
	private String academicDirectorName; // 主任委员姓名
	private String academicDirectorDuty; // 职务
	private String academicDirectorProfessional; // 职称
	private String academicDirectorSpecialty; // 专业
	private String academicDirectorUnit; // 单位

	// 伦理委员会
	private String ethicalPdf; // pdf资料
	private String ethicalDirectorName; // 主任委员姓名
	private String ethicalDirectorDuty; // 职务
	private String ethicalDirectorProfessional; // 职称
	private String ethicalDirectorSpecialty; // 专业
	private String ethicalDirectorUnit; // 单位

	// 干细胞制备标准操作规范及人员条件
	private String preparationStandardDevice; // 干细胞制备主要设施设备
	private String preparationStandardConditionPdf; // 人员条件

	// 细胞临床研究质量管理文件及风险控制程序和相关文件
	private String studyQualityManagementDocumentRoutine; // 临床研究工作程序
	private String studyQualityManagementDocumentSheet; // 标准操作规范和试验记录
	private String studyQualityManagementDocumentElse; // 其他

	// 干细胞临床研究审计体系
	private String auditSystemEvidencePdf; // 证明文件
	private String auditSystemInstitutionPdf;// 外审（外部质量控制）制度（上传）

	// 干细胞评价标准
	private String evaluationCriterionMonitoringDevice; // 干细胞检测设备设施情况
	private String otherRelevantInformation; // 其他相关材料（上传）

	// 伦理委员会注册信息 2016-06-07 14:51:23
	private String institutionEthicsCommitteeName; // 机构伦理委员会名称
	private String institutionEthicsCommitteePersonnel; // 机构伦理委员会人员情况
	private String institutionEthicsCommitteeConstitution; // 是否具有机构伦理委员会章程
	private String institutionEthicsCommitteeProgram; // 机构伦理委员会是否具有工作制度或相关工作程序

	// 2016-12-8 21:35:14 xiaoan
	private String isNationalTwoCommittees; // 是否为国家两委局批准的干细胞临床研究机构
	private String isInvolvedPerson; // 是否为涉及人的生物医学研究机构

	// 2016-04-15 16:53:59 end xiaoan

	private String reason; // 不能过原因
	private Integer state; // 通过状态
	private Integer status; // 通过状态

	private String username;
	private String truename;
	private String password;
	private String param;

	private int defaultPageShowCount = 15;

	private String searchText;
	private String country;

	private String mWebAppDir;
	private File mGeneratedDir;
	private static final String GENERATED_DIR_SHORT_NAME = "generated";
	private static final String CONTENT_TYPE = "text/html; charset=GBK";

	public void init() {
		try {
			loadLicense();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void loadLicense() throws Exception {
		File licenseFile = new File(this.mWebAppDir,
				"WEB-INF//Aspose.Words.lic");
		if (licenseFile.exists()) {
			License license = new License();

			license.setLicense(licenseFile.getAbsolutePath());
		}
	}

	public String exportOrgInfo() {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		this.mWebAppDir = request.getRealPath("/");
		System.out.println("路劲=" + request.getRealPath("/"));

		String[] fieldNames = (String[]) null;
		String[] fieldVal = (String[]) null;

		User aUser = (User) super.getSession().getAttribute("user");

		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("org", aUser.getOrganization());

		OrganizationRecords aOrganizationRecords = null;
		List<OrganizationRecords> list = organizationRecordsService
				.findByProperty("organization.id", aUser.getOrganization()
						.getId());
		if (list.size() > 0) {
			aOrganizationRecords = list.get(0);
		}
		try {
			init();
			request.setCharacterEncoding("gbk");
			response.setCharacterEncoding("gbk");
			Document doc = null;
			doc = new Document(this.mWebAppDir + "//template//org_template.doc");
			fieldNames = new String[] { "regNumber", "name", "organType",
					"organLevel", "organCode", "province", "address",
					"postCode", "contactUser", "contactPhone", "contactMobile",
					"contactEmail", "responsiblePerson", "a1", "b1", "a2",
					"b2", "a3", "b3", "a4", "b4", "a5", "b5", "a6", "b6", "a7",
					"b7", "a8", "b8", "a9", "b9", "a10", "b10", "a11", "b11",
					"a12", "b12", "a13", "b13", "a14", "b14" };
			fieldVal = new String[fieldNames.length];
			// for (int i = 0; i < fieldNames.length; i++) {
			// String valueStr = "";
			// if (fieldNames[i].equals("name")
			// || fieldNames[i].equals("organType")
			// || fieldNames[i].equals("organLevel")
			// || fieldNames[i].equals("organCode")
			// || fieldNames[i].equals("address")
			// || fieldNames[i].equals("postCode")
			// || fieldNames[i].equals("contactUser")
			// || fieldNames[i].equals("contactPhone")
			// || fieldNames[i].equals("contactMobile")
			// || fieldNames[i].equals("contactEmail")
			// || fieldNames[i].equals("responsiblePerson")) {
			// Method method = aOrganizationRecords
			// .getOrganization()
			// .getClass()
			// .getMethod(
			// "get"
			// + StringUtils
			// .capitalize((String) fieldNames[i]),
			// (Class[]) null);
			// if (method.invoke(aOrganizationRecords.getOrganization(),
			// null) != null) {
			// valueStr = method.invoke(aOrganizationRecords
			// .getOrganization(), null)
			// + "";
			// }
			// } else if (fieldNames[i].equals("province")) {
			// valueStr = aOrganizationRecords.getOrganization()
			// .getProvince().getShortName();
			// } else if (fieldNames[i].equals("a1")) {
			// if (!"".equals(aOrganizationRecords
			// .getMedicalInstitutionsExequatur())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b1")) {
			// if (!"".equals(aOrganizationRecords
			// .getMedicalInstitutionsExequatur())) {
			// valueStr = "";
			// } else {
			// valueStr = "√";
			// }
			// } else if (fieldNames[i].equals("a2")) {
			// if (!"".equals(aOrganizationRecords
			// .getMedicalClinicalTestCertificate())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b2")) {
			// if (!"".equals(aOrganizationRecords
			// .getMedicalClinicalTestCertificate())) {
			// valueStr = "";
			// } else {
			// valueStr = "√";
			// }
			// } else if (fieldNames[i].equals("a3")) {
			// if (!""
			// .equals(aOrganizationRecords
			// .getOrganizationScheme())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b3")) {
			// if (!""
			// .equals(aOrganizationRecords
			// .getOrganizationScheme())) {
			// valueStr = "";
			// } else {
			// valueStr = "√";
			// }
			// } else if (fieldNames[i].equals("a4")) {
			// if (!"".equals(aOrganizationRecords
			// .getResearchManagementPrincipal())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b4")) {
			// if (!"".equals(aOrganizationRecords
			// .getResearchManagementPrincipal())) {
			// valueStr = "";
			// } else {
			// valueStr = "√";
			// }
			// } else if (fieldNames[i].equals("a5")) {
			// if (!"".equals(aOrganizationRecords
			// .getResearchManagementAttorney())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b5")) {
			// if (!"".equals(aOrganizationRecords
			// .getResearchManagementAttorney())) {
			// valueStr = "";
			// } else {
			// valueStr = "√";
			// }
			// } else if (fieldNames[i].equals("a6")) {
			// if ("1".equals(aOrganizationRecords.getIsReceiveTraining())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b6")) {
			// if ("0".equals(aOrganizationRecords.getIsReceiveTraining())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a7")) {
			// if ("1".equals(aOrganizationRecords
			// .getIsAcademicAndEthical())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b7")) {
			// if ("0".equals(aOrganizationRecords
			// .getIsAcademicAndEthical())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a8")) {
			// if ("1".equals(aOrganizationRecords.getIsWorkingSystem())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b8")) {
			// if ("0".equals(aOrganizationRecords.getIsWorkingSystem())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a9")) {
			// if ("1".equals(aOrganizationRecords
			// .getIsPreparationStandard())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b9")) {
			// if ("0".equals(aOrganizationRecords
			// .getIsPreparationStandard())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a10")) {
			// if ("1".equals(aOrganizationRecords
			// .getIsStudyQualityManagementDocument())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b10")) {
			// if ("0".equals(aOrganizationRecords
			// .getIsStudyQualityManagementDocument())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a11")) {
			// if ("1".equals(aOrganizationRecords.getIsAuditSystem())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b11")) {
			// if ("0".equals(aOrganizationRecords.getIsAuditSystem())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a12")) {
			// if ("1".equals(aOrganizationRecords
			// .getIsEvaluationCriterion())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b12")) {
			// if ("0".equals(aOrganizationRecords
			// .getIsEvaluationCriterion())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a13")) {
			// if ("1".equals(aOrganizationRecords
			// .getIsRiskManagementMechanism())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b13")) {
			// if ("0".equals(aOrganizationRecords
			// .getIsRiskManagementMechanism())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("a14")) {
			// if ("1"
			// .equals(aOrganizationRecords
			// .getIsTreatmentMeasure())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else if (fieldNames[i].equals("b14")) {
			// if ("0"
			// .equals(aOrganizationRecords
			// .getIsTreatmentMeasure())) {
			// valueStr = "√";
			// } else {
			// valueStr = "";
			// }
			// } else {
			// Method method = aOrganizationRecords
			// .getClass()
			// .getMethod(
			// "get"
			// + StringUtils
			// .capitalize((String) fieldNames[i]),
			// (Class[]) null);
			// if (method.invoke(aOrganizationRecords, null) != null) {
			// valueStr = method.invoke(aOrganizationRecords, null)
			// + "";
			// }
			// }
			// fieldVal[i] = valueStr;
			// }

			doc.getMailMerge().execute(fieldNames, fieldVal);

			File fileLogo = new File(this.mWebAppDir + "template//logo.png");
			InputStream in = new FileInputStream(fileLogo);
			insertWatermarkText(doc, in);

			// doc.save(this.mWebAppDir + "template//"
			// + "高新认定申请表20140603.doc", 10);

			String pdfName = "干细胞临床研究机构备案" + System.currentTimeMillis()
					+ ".pdf";

			PdfSaveOptions pdfoption = new PdfSaveOptions();

			doc.save(this.mWebAppDir + "file_temp//" + pdfName, pdfoption);

			File file = new File(this.mWebAppDir + "file_temp//" + pdfName);

			response.reset();
			response.setContentType("application/OCTET-STREAM;charset=GB2312");
			pdfName = URLEncoder.encode(pdfName, "UTF-8");
			response.setHeader("Content-Disposition", "attachment; filename="
					+ new String(pdfName.getBytes("utf-8"), "gbk"));
			response.setContentLength((int) file.length());

			ServletOutputStream sos = response.getOutputStream();
			FileInputStream fis = new FileInputStream(file);
			byte[] buffer = new byte[1024];
			int i = 0;
			while ((i = fis.read(buffer)) != -1) {
				sos.write(buffer, 0, i);
				sos.flush();
			}
			sos.close();
			fis.close();

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return null;
	}

	private static void insertWatermarkText(Document doc, InputStream in)
			throws Exception {
		Shape watermark = new Shape(doc, ShapeType.IMAGE);
		watermark.getImageData().setImage(in);
		// watermark.getTextPath().setText("F.S.P");
		// watermark.getTextPath().setFontFamily("宋体");
		watermark.setWidth(300D);
		watermark.setHeight(96D);
		watermark.setRotation(1D);
		// watermark.getFill().setColor(new Color(234, 234, 234));
		// watermark.setStrokeColor(new Color(255, 255, 255));
		watermark.setRelativeHorizontalPosition(1);
		watermark.setRelativeVerticalPosition(1);
		watermark.setWrapType(3);
		watermark.setVerticalAlignment(2);
		watermark.setHorizontalAlignment(2);
		Paragraph watermarkPara = new Paragraph(doc);
		watermarkPara.appendChild(watermark);
		for (Section sect : doc.getSections()) {
			insertWatermarkIntoHeader(watermarkPara, sect, 1);
			insertWatermarkIntoHeader(watermarkPara, sect, 4);
			insertWatermarkIntoHeader(watermarkPara, sect, 0);
		}
	}

	private static void insertWatermarkIntoHeader(Paragraph watermarkPara,
			Section sect, int headerType) throws Exception {
		HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(
				headerType);
		if (header == null) {
			header = new HeaderFooter(sect.getDocument(), headerType);

			sect.getHeadersFooters().add(header);
		}
		header.appendChild(watermarkPara.deepClone(true));
	}

	public String findEntityById() {
		User aUser = (User) getSession().getAttribute("user");
		String detailShow = "false"; // 详情页区域权限控制 true=显示
		if (id == null) {
			return null;
		}
		Map<Object, Object> map = new HashMap<Object, Object>();
		try {
			List<OrganizationRecords> list = organizationRecordsService
					.findByProperty("organization.id", Integer.parseInt(id));
			if (null != list && list.size() > 0) {
				OrganizationRecords organizationRecords = list.get(0);
				Organization aOrganization = organizationRecords
						.getOrganization();

				// 判断权限
				if(aUser != null && !"".equals(aUser)){
					if ("admin".equals(aUser.getUsername())&& aUser.getRoleType() == 0) {
						detailShow = "true";
					} else if (aUser.getRoleType() == 1&& aUser.getProvince().getCode().equals(aOrganization.getProvince().getCode())) {
						detailShow = "true";
					} else if (aUser.getRoleType() == 2&& aUser.getOrganization().getId().equals(aOrganization.getId())) {
						detailShow = "true";
					} else if (aUser.getRoleType() == 3&& aUser.getOrganization().getId().equals(aOrganization.getId())) {
						detailShow = "true";
					} else {
						detailShow = "false";
					}
				} else {
					detailShow = "false";
				}
					
				System.out.println("detailShow=" + detailShow);

				map.put("detailShow", detailShow);
				map.put("orgRecords", organizationRecords);
				map.put("org", organizationRecords.getOrganization());
				List<OrganizationRecordsCertificate> ocList = organizationRecordsCertificateService
						.findByProperty("organizationRecords",
								organizationRecords);
				if (null != ocList && ocList.size() > 0) {
					OrganizationRecordsCertificate organizationRecordsCertificate = ocList
							.get(0);
					map.put("organizationRecordsCertificate",
							organizationRecordsCertificate);
				} else {
					map.put("organizationRecordsCertificate", "");
				}
			} else {
				map.put("orgRecords", "");
			}

			super.printWriterJsonToPage(JsonUtil.formatMapToJson(map));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public String findUserOrgById() {
		User aUser = (User) super.getSession().getAttribute("user");

		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("org", aUser.getOrganization());

		try {
			List<OrganizationRecords> list = organizationRecordsService
					.findByProperty("organization.id", aUser.getOrganization()
							.getId());

			if (null != list && list.size() > 0) {
				OrganizationRecords organizationRecords = list.get(0);
				map.put("orgRecords", organizationRecords);

				// List<OrganizationRecordsCertificate> ocList =
				// organizationRecordsCertificateService
				// .findByProperty("organizationRecords",
				// organizationRecords);
				// if (null != ocList && ocList.size() > 0) {
				// OrganizationRecordsCertificate organizationRecordsCertificate
				// = ocList
				// .get(0);
				// map.put("organizationRecordsCertificate",
				// organizationRecordsCertificate);
				// } else {
				// map.put("organizationRecordsCertificate", "");
				// }
			} else {
				map.put("orgRecords", "");
			}

			super.printWriterJsonToPage(JsonUtil.formatMapToJson(map));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public String getPageCount() throws Exception {
		// TODO Auto-generated method stub
		if (searchText == null || "请输入名称".equals(searchText) || "机构名称".equals(searchText)) {
			searchText = "";
		}
		int count = searchOrganization(searchText);
		String content = JsonUtil.formatToJson(count);
		super.pringWriterToPage(content);
		return null;
	}

	public int searchOrganization(String sql) {
		int result = 0;
		List<OrganizationRecords> list = new ArrayList<OrganizationRecords>();
		if (state == 1) {
			if (null != province && province.length() > 0) {
				list = organizationRecordsService
						.findByPropertys(
								"o.organization.name like ? and o.status=? and o.organization.province.code=?",
								new Object[] { "%" + sql + "%", state, province });
			} else {
				list = organizationRecordsService.findByPropertys(
						"o.organization.name like ? and o.status=?",
						new Object[] { "%" + sql + "%", state });
			}
		} else if (state == 2) {
			User userS = (User) getSession().getAttribute("user");
			list = organizationRecordsService
					.findByPropertys(
							"o.organization.name like ? and o.organization.province.code=? and o.status=?",
							new Object[] { "%" + sql + "%",
									userS.getProvince().getCode(), 0 });

		}
		if (null != list) {
			result = Integer.valueOf(String.valueOf(list.size()));
		}
		return result;
	}

	public String getPageList() throws Exception {
		// TODO Auto-generated method stub
		if (searchText == null || "请输入名称".equals(searchText) || "机构名称".equals(searchText)) {
			searchText = "";
		}
		List<Map<Object, Object>> result = new ArrayList<Map<Object, Object>>();
		List<OrganizationRecords> list = null;
		try {

			int page = Integer.valueOf(pageIndex);
			int maxResult = Integer.valueOf(pageShowCount);
			int firstResult = maxResult * page;

			list = searchOrg(searchText, firstResult, maxResult);
			if (null != list) {
				Map<Object, Object> map = null;
				for (OrganizationRecords objRecodes : list) {
					Organization obj = objRecodes.getOrganization();
					map = new HashMap<Object, Object>();
					map.put("id", obj.getId());
					map.put("name", obj.getName());
					map.put("regNumber", objRecodes.getRegNumber());
					map.put("organLevel", obj.getOrganLevel());
					map.put("province", obj.getProvince().getShortName());
					map.put("status", objRecodes.getStatus());
					map.put("createdate", obj.getCreateTime());
					result.add(map);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		String content = JsonUtil.formatToJson(result);
		super.pringWriterToPage(content);
		return null;
	}

	public List<OrganizationRecords> searchOrg(String sql, int firstResult,
			int maxResult) {
		List<OrganizationRecords> list = new ArrayList<OrganizationRecords>();
		if (state == 1) {
			if (null != province && province.length() > 0) {
				list = organizationRecordsService
						.findByPropertys(
								firstResult,
								maxResult,
								"o.organization.name like ? and o.status=? and o.organization.province.code=?",
								new Object[] { "%" + sql + "%", state, province },
								null);
			} else {
				list = organizationRecordsService.findByPropertys(firstResult,
						maxResult, "o.organization.name like ? and o.status=?",
						new Object[] { "%" + sql + "%", state }, null);
			}

		} else if (state == 2) {
			User userS = (User) getSession().getAttribute("user");
			list = organizationRecordsService
					.findByPropertys(
							firstResult,
							maxResult,
							"o.organization.name like ? and o.organization.province.code=? and o.status=?",
							new Object[] { "%" + sql + "%",
									userS.getProvince().getCode(), 0 }, null);
		}

		return list;
	}

	/** ** 项目情况 s ** */

	public String editAssumeProject() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (aUser != null) {

			if (id != null && !"".equals(id)) {
				OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = organizationRecordsAssumeProjectService
						.find(Integer.parseInt(id));
				aOrganizationRecordsAssumeProject.setProjectType(projectType);
				aOrganizationRecordsAssumeProject.setProjectName(projectName);
				aOrganizationRecordsAssumeProject
						.setProjectNumber(projectNumber);
				aOrganizationRecordsAssumeProject.setPrincipal(principal);
				aOrganizationRecordsAssumeProject.setExpenditure(expenditure);
				aOrganizationRecordsAssumeProject.setLeaderUnit(leaderUnit);
				aOrganizationRecordsAssumeProject
						.setParticipationUnit(participationUnit);
				organizationRecordsAssumeProjectService
						.updateEntity(aOrganizationRecordsAssumeProject);
				super.pringWriterToPage("success");
				return null;
			} else {
				OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = new OrganizationRecordsAssumeProject();
				aOrganizationRecordsAssumeProject.setProjectType(projectType);
				aOrganizationRecordsAssumeProject.setProjectName(projectName);
				aOrganizationRecordsAssumeProject
						.setProjectNumber(projectNumber);
				aOrganizationRecordsAssumeProject.setPrincipal(principal);
				aOrganizationRecordsAssumeProject.setExpenditure(expenditure);
				aOrganizationRecordsAssumeProject.setLeaderUnit(leaderUnit);
				aOrganizationRecordsAssumeProject
						.setParticipationUnit(participationUnit);
				aOrganizationRecordsAssumeProject.setUsername(aUser
						.getUsername());
				organizationRecordsAssumeProjectService
						.saveEntity(aOrganizationRecordsAssumeProject);
				super.pringWriterToPage("success");
				return null;
			}
		} else {
			super.pringWriterToPage("error");
		}

		return null;
	}

	public String findAssumeProject() throws Exception {
		if (id != null && !"".equals(id)) {
			OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = organizationRecordsAssumeProjectService
					.find(Integer.parseInt(id));
			super.printWriterJsonToPage(JsonUtil
					.formatToJson(aOrganizationRecordsAssumeProject));
		}
		return null;
	}

	public String getAssumeProjectList() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (id != null && !"".equals(id)) {
			List<OrganizationRecords> orList = organizationRecordsService
					.findByPropertys("o.organization.id=?",
							new Object[] { Integer.parseInt(id) });
			if (orList.size() > 0) {
				List<OrganizationRecordsAssumeProject> orcList = organizationRecordsAssumeProjectService
						.findByPropertys("o.organizationRecords=?",
								new Object[] { orList.get(0) });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}
		} else {
			if (aUser != null) {
				List<OrganizationRecordsAssumeProject> orcList = organizationRecordsAssumeProjectService
						.findByPropertys("o.username=?", new Object[] { aUser
								.getUsername() });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}
		}
		return null;
	}

	public String deleteAssumeProject() throws Exception {
		if (id != null && !"".equals(id)) {
			organizationRecordsAssumeProjectService.deleteEntity(Integer
					.parseInt(id));
			super.pringWriterToPage("success");
		}
		return null;
	}

	/** ** 项目情况 e ** */

	/** ** 委员情况 s ** */

	public String editCommittee() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (aUser != null) {
			if (id != null && !"".equals(id)) {
				OrganizationRecordsCommittee aOrganizationRecordsCommittee = organizationRecordsCommitteeService
						.find(Integer.parseInt(id));
				aOrganizationRecordsCommittee.setMemberName(memberName);
				aOrganizationRecordsCommittee.setDuty(duty);
				aOrganizationRecordsCommittee.setProfessional(professional);
				aOrganizationRecordsCommittee.setSpecialty(specialty);
				aOrganizationRecordsCommittee.setUnit(unit);
				aOrganizationRecordsCommittee.setMemberType(memberType);
				aOrganizationRecordsCommittee.setCommitteeType(committeeType);
				organizationRecordsCommitteeService
						.updateEntity(aOrganizationRecordsCommittee);
				super.pringWriterToPage("success");
				return null;
			} else {
				OrganizationRecordsCommittee aOrganizationRecordsCommittee = new OrganizationRecordsCommittee();
				aOrganizationRecordsCommittee.setMemberName(memberName);
				aOrganizationRecordsCommittee.setDuty(duty);
				aOrganizationRecordsCommittee.setProfessional(professional);
				aOrganizationRecordsCommittee.setSpecialty(specialty);
				aOrganizationRecordsCommittee.setUnit(unit);
				aOrganizationRecordsCommittee.setMemberType(memberType);
				aOrganizationRecordsCommittee.setCommitteeType(committeeType);
				aOrganizationRecordsCommittee.setUsername(aUser.getUsername());
				organizationRecordsCommitteeService
						.saveEntity(aOrganizationRecordsCommittee);

				super.pringWriterToPage("success");
				return null;
			}
		} else {
			super.pringWriterToPage("error");
		}

		return null;
	}

	public String findCommittee() throws Exception {
		if (id != null && !"".equals(id)) {
			OrganizationRecordsCommittee aOrganizationRecordsCommittee = organizationRecordsCommitteeService
					.find(Integer.parseInt(id));
			super.printWriterJsonToPage(JsonUtil
					.formatToJson(aOrganizationRecordsCommittee));
		}
		return null;
	}

	public String getCommitteeList() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (id != null && !"".equals(id)) {
			List<OrganizationRecords> orList = organizationRecordsService
					.findByPropertys("o.organization.id=?",
							new Object[] { Integer.parseInt(id) });
			if (orList.size() > 0) {
				List<OrganizationRecordsCommittee> orcList = organizationRecordsCommitteeService
						.findByPropertys(
								"o.organizationRecords=? and o.memberType=? and o.committeeType=?",
								new Object[] { orList.get(0), memberType,
										committeeType });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}

		} else {
			if (aUser != null) {
				List<OrganizationRecordsCommittee> orcList = organizationRecordsCommitteeService
						.findByPropertys(
								"o.username=? and o.memberType=? and o.committeeType=?",
								new Object[] { aUser.getUsername(), memberType,
										committeeType });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}
		}

		return null;
	}

	public String deleteCommittee() throws Exception {
		if (id != null && !"".equals(id)) {
			organizationRecordsCommitteeService.deleteEntity(Integer
					.parseInt(id));
			super.pringWriterToPage("success");
		}
		return null;
	}

	/** ** 委员 e ** */

	/** ** 内审情况 s ** */

	public String editInternalAudit() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (aUser != null) {
			if (id != null && !"".equals(id)) {
				OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = organizationRecordsInternalAuditService
						.find(Integer.parseInt(id));
				aOrganizationRecordsInternalAudit.setMemberName(memberName);
				aOrganizationRecordsInternalAudit.setSpecialty(specialty);
				aOrganizationRecordsInternalAudit.setDepartment(department);
				organizationRecordsInternalAuditService
						.updateEntity(aOrganizationRecordsInternalAudit);
				super.pringWriterToPage("success");
				return null;
			} else {
				OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = new OrganizationRecordsInternalAudit();
				aOrganizationRecordsInternalAudit.setMemberName(memberName);
				aOrganizationRecordsInternalAudit.setSpecialty(specialty);
				aOrganizationRecordsInternalAudit.setDepartment(department);
				aOrganizationRecordsInternalAudit.setUsername(aUser
						.getUsername());
				organizationRecordsInternalAuditService
						.saveEntity(aOrganizationRecordsInternalAudit);
				super.pringWriterToPage("success");
				return null;
			}
		} else {
			super.pringWriterToPage("error");
		}

		return null;
	}

	public String findInternalAudit() throws Exception {
		if (id != null && !"".equals(id)) {
			OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = organizationRecordsInternalAuditService
					.find(Integer.parseInt(id));
			super.printWriterJsonToPage(JsonUtil
					.formatToJson(aOrganizationRecordsInternalAudit));
		}
		return null;
	}

	public String getInternalAuditList() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (id != null && !"".equals(id)) {
			List<OrganizationRecords> orList = organizationRecordsService
					.findByPropertys("o.organization.id=?",
							new Object[] { Integer.parseInt(id) });
			if (orList.size() > 0) {
				List<OrganizationRecordsInternalAudit> orcList = organizationRecordsInternalAuditService
						.findByPropertys("o.organizationRecords=?",
								new Object[] { orList.get(0) });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}

		} else {
			if (aUser != null) {
				List<OrganizationRecordsInternalAudit> orcList = organizationRecordsInternalAuditService
						.findByPropertys("o.username=?", new Object[] { aUser
								.getUsername() });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}
		}

		return null;
	}

	public String deleteInternalAudit() throws Exception {
		if (id != null && !"".equals(id)) {
			organizationRecordsInternalAuditService.deleteEntity(Integer
					.parseInt(id));
			super.pringWriterToPage("success");
		}
		return null;
	}

	/** ** 内审 e ** */

	public String editCertificate() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (aUser != null) {
			if (id != null && !"".equals(id)) {
				OrganizationRecordsCertificate aOrganizationRecordsCertificate = organizationRecordsCertificateService
						.find(Integer.parseInt(id));
				aOrganizationRecordsCertificate.setPdf(pdf);
				aOrganizationRecordsCertificate.setCertNumber(certNumber);
				aOrganizationRecordsCertificate
						.setAffirmationProfession(affirmationProfession);
				aOrganizationRecordsCertificate.setStartDate(startDate);
				aOrganizationRecordsCertificate.setEndDate(endDate);
				organizationRecordsCertificateService
						.updateEntity(aOrganizationRecordsCertificate);
				super.pringWriterToPage("success");
				return null;
			} else {
				OrganizationRecordsCertificate aOrganizationRecordsCertificate = new OrganizationRecordsCertificate();
				aOrganizationRecordsCertificate.setPdf(pdf);
				aOrganizationRecordsCertificate.setCertNumber(certNumber);
				aOrganizationRecordsCertificate
						.setAffirmationProfession(affirmationProfession);
				aOrganizationRecordsCertificate.setStartDate(startDate);
				aOrganizationRecordsCertificate.setEndDate(endDate);
				aOrganizationRecordsCertificate
						.setUsername(aUser.getUsername());
				organizationRecordsCertificateService
						.saveEntity(aOrganizationRecordsCertificate);
				super.pringWriterToPage("success");
				return null;
			}
		} else {
			super.pringWriterToPage("error");
		}

		return null;
	}

	public String findCertificate() throws Exception {
		if (id != null && !"".equals(id)) {
			OrganizationRecordsCertificate aOrganizationRecordsCertificate = organizationRecordsCertificateService
					.find(Integer.parseInt(id));
			super.printWriterJsonToPage(JsonUtil
					.formatToJson(aOrganizationRecordsCertificate));
		}
		return null;
	}

	public String getCertificateList() throws Exception {
		User aUser = (User) getSession().getAttribute("user");
		if (id != null && !"".equals(id)) {
			List<OrganizationRecords> orList = organizationRecordsService
					.findByPropertys("o.organization.id=?",
							new Object[] { Integer.parseInt(id) });
			if (orList.size() > 0) {
				List<OrganizationRecordsCertificate> orcList = organizationRecordsCertificateService
						.findByPropertys("o.organizationRecords=?",
								new Object[] { orList.get(0) });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}

		} else {
			if (aUser != null) {
				List<OrganizationRecordsCertificate> orcList = organizationRecordsCertificateService
						.findByPropertys("o.username=?", new Object[] { aUser
								.getUsername() });
				super.printWriterJsonToPage(JsonUtil.formatToJson(orcList));
			}
		}
		return null;
	}

	public String deleteCertificate() throws Exception {
		if (id != null && !"".equals(id)) {
			organizationRecordsCertificateService.deleteEntity(Integer
					.parseInt(id));
			super.pringWriterToPage("success");
		}
		return null;
	}

	/**
	 * 2016-11-27 20:41:45 xiaoan 机构备案保存功能
	 * 
	 * @return
	 * @throws Exception
	 */
	public String saveOrgBySave() throws Exception {

		User userS = (User) getSession().getAttribute("user");
		if (userS != null) {
			try {
				Organization organization = organizationService.find(userS
						.getOrganization().getId());

				organization.setOrganType(organType);
				organization.setOrganLevel(organLevel);
				organization.setAddress(address);
				organization.setPostCode(postCode);
				organization.setContactEmail(contactEmail);
				organization.setContactMobile(contactMobile);
				organization.setContactPhone(contactPhone);
				organization.setContactUser(contactUser);
				organization.setResponsiblePerson(responsiblePerson);

				organization.setCreateTime(DateUtils.getDateTime());
				organization.setCreateUser(userS.getName());

				organizationService.updateEntity(organization);

				userS.setOrganization(organization);
				getSession().setAttribute("user", userS);

				List<OrganizationRecords> list = organizationRecordsService
						.findByProperty("organization.id", userS
								.getOrganization().getId());

				if (null != list && list.size() > 0) {
					OrganizationRecords organizationRecords = list.get(0);

					organizationRecords.setOrganization(organization);
					organizationRecords.setStatus(-1);

					organizationRecords
							.setMedicalInstitutionsExequaturPdf(medicalInstitutionsExequaturPdf);
					organizationRecords
							.setMedicalInstitutionsExequaturSubject(medicalInstitutionsExequaturSubject);
					organizationRecords
							.setMedicalInstitutionsExequaturStartDate(medicalInstitutionsExequaturStartDate);
					organizationRecords
							.setMedicalInstitutionsExequaturEndDate(medicalInstitutionsExequaturEndDate);
					organizationRecords
							.setMedicalInstitutionsExequaturRegisterNum(medicalInstitutionsExequaturRegisterNum);
					organizationRecords
							.setOrganizationScheme(organizationScheme);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementPrincipalResponsible(researchManagementPrincipalResponsible);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementAttorneyQualifiedPerson(researchManagementAttorneyQualifiedPerson);
					organizationRecords
							.setReceiveTrainingPdf(receiveTrainingPdf);
					// organizationRecords.setAcademicAndEthicalPdf(academicAndEthicalPdf);
					organizationRecords.setWorkingSystemPdf(workingSystemPdf);
					organizationRecords
							.setPreparationStandardPdf(preparationStandardPdf);
					organizationRecords
							.setStudyQualityManagementDocumentPdf(studyQualityManagementDocumentPdf);
					organizationRecords.setAuditSystemPdf(auditSystemPdf);
					organizationRecords
							.setEvaluationCriterionPdf(evaluationCriterionPdf);
					organizationRecords
							.setRiskManagementMechanismPdf(riskManagementMechanismPdf);
					organizationRecords
							.setTreatmentMeasurePdf(treatmentMeasurePdf);
					organizationRecords
							.setResearchManagementPrincipalPdf(researchManagementPrincipalPdf);
					// 清空审核信息
					organizationRecords.setReason(null);

					// 2016-04-21 10:27:19 xiaoan start
					organizationRecords
							.setResearchManagementPrincipalDuty(researchManagementPrincipalDuty);
					organizationRecords
							.setResearchManagementPrincipalProfessional(researchManagementPrincipalProfessional);
					organizationRecords
							.setResearchManagementPrincipalSpecialty(researchManagementPrincipalSpecialty);
					organizationRecords
							.setResearchManagementPrincipalCertificatePdf(researchManagementPrincipalCertificatePdf);
					organizationRecords
							.setResearchManagementAttorneyDuty(researchManagementAttorneyDuty);
					organizationRecords
							.setResearchManagementAttorneyProfessional(researchManagementAttorneyProfessional);
					organizationRecords
							.setResearchManagementAttorneySpecialty(researchManagementAttorneySpecialty);
					organizationRecords
							.setResearchManagementAttorneyEducation(researchManagementAttorneyEducation);
					organizationRecords
							.setResearchManagementAttorneyLimit(researchManagementAttorneyLimit);
					organizationRecords
							.setResearchManagementAttorneyExperiencePdf(researchManagementAttorneyExperiencePdf);
					organizationRecords
							.setEthicalTrainingPdf(ethicalTrainingPdf);
					organizationRecords.setAcademicPdf(academicPdf);
					organizationRecords
							.setAcademicDirectorName(academicDirectorName);
					organizationRecords
							.setAcademicDirectorDuty(academicDirectorDuty);
					organizationRecords
							.setAcademicDirectorProfessional(academicDirectorProfessional);
					organizationRecords
							.setAcademicDirectorSpecialty(academicDirectorSpecialty);
					organizationRecords
							.setAcademicDirectorUnit(academicDirectorUnit);
					organizationRecords.setEthicalPdf(ethicalPdf);
					organizationRecords
							.setEthicalDirectorName(ethicalDirectorName);
					organizationRecords
							.setEthicalDirectorDuty(ethicalDirectorDuty);
					organizationRecords
							.setEthicalDirectorProfessional(ethicalDirectorProfessional);
					organizationRecords
							.setEthicalDirectorSpecialty(ethicalDirectorSpecialty);
					organizationRecords
							.setEthicalDirectorUnit(ethicalDirectorUnit);
					organizationRecords
							.setPreparationStandardDevice(preparationStandardDevice);
					organizationRecords
							.setPreparationStandardConditionPdf(preparationStandardConditionPdf);
					organizationRecords
							.setStudyQualityManagementDocumentRoutine(studyQualityManagementDocumentRoutine);
					organizationRecords
							.setStudyQualityManagementDocumentSheet(studyQualityManagementDocumentSheet);
					organizationRecords
							.setStudyQualityManagementDocumentElse(studyQualityManagementDocumentElse);
					organizationRecords
							.setAuditSystemEvidencePdf(auditSystemEvidencePdf);
					organizationRecords
							.setAuditSystemInstitutionPdf(auditSystemInstitutionPdf);
					organizationRecords
							.setEvaluationCriterionMonitoringDevice(evaluationCriterionMonitoringDevice);
					organizationRecords
							.setOtherRelevantInformation(otherRelevantInformation);
					// 2016-04-21 10:27:19 xiaoan end

					organizationRecordsService
							.updateEntity(organizationRecords);

					// 2016-11-20 23:11:44 xiaoan start
					// 药物临床试验机构资格认定证书
					List<OrganizationRecordsCertificate> orcList = organizationRecordsCertificateService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcList.size(); i++) {
						OrganizationRecordsCertificate aOrganizationRecordsCertificate = orcList
								.get(i);
						aOrganizationRecordsCertificate
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCertificateService
								.updateEntity(aOrganizationRecordsCertificate);
					}
					// 机构承担项目情况
					List<OrganizationRecordsAssumeProject> oraList = organizationRecordsAssumeProjectService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oraList.size(); i++) {
						OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = oraList
								.get(i);
						aOrganizationRecordsAssumeProject
								.setOrganizationRecords(organizationRecords);
						organizationRecordsAssumeProjectService
								.updateEntity(aOrganizationRecordsAssumeProject);
					}
					// 内审人员信息
					List<OrganizationRecordsInternalAudit> oriList = organizationRecordsInternalAuditService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oriList.size(); i++) {
						OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = oriList
								.get(i);
						aOrganizationRecordsInternalAudit
								.setOrganizationRecords(organizationRecords);
						organizationRecordsInternalAuditService
								.updateEntity(aOrganizationRecordsInternalAudit);
					}
					// 学术委员会
					List<OrganizationRecordsCommittee> orcoList = organizationRecordsCommitteeService
							.findByPropertys("o.username=? ",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcoList.size(); i++) {
						OrganizationRecordsCommittee aOrganizationRecordsCommittee = orcoList
								.get(i);
						aOrganizationRecordsCommittee
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCommitteeService
								.updateEntity(aOrganizationRecordsCommittee);
					}
					// 2016-11-20 23:11:44 xiaoan end

				} else {
					OrganizationRecords organizationRecords = new OrganizationRecords();

					organizationRecords.setOrganization(organization);
					organizationRecords.setStatus(-1);

					organizationRecords
							.setMedicalInstitutionsExequaturPdf(medicalInstitutionsExequaturPdf);
					organizationRecords
							.setMedicalInstitutionsExequaturSubject(medicalInstitutionsExequaturSubject);
					organizationRecords
							.setMedicalInstitutionsExequaturStartDate(medicalInstitutionsExequaturStartDate);
					organizationRecords
							.setMedicalInstitutionsExequaturEndDate(medicalInstitutionsExequaturEndDate);
					organizationRecords
							.setMedicalInstitutionsExequaturRegisterNum(medicalInstitutionsExequaturRegisterNum);
					organizationRecords
							.setOrganizationScheme(organizationScheme);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementPrincipalResponsible(researchManagementPrincipalResponsible);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementAttorneyQualifiedPerson(researchManagementAttorneyQualifiedPerson);
					organizationRecords
							.setReceiveTrainingPdf(receiveTrainingPdf);
					// organizationRecords.setAcademicAndEthicalPdf(academicAndEthicalPdf);
					organizationRecords.setWorkingSystemPdf(workingSystemPdf);
					organizationRecords
							.setPreparationStandardPdf(preparationStandardPdf);
					organizationRecords
							.setStudyQualityManagementDocumentPdf(studyQualityManagementDocumentPdf);
					organizationRecords.setAuditSystemPdf(auditSystemPdf);
					organizationRecords
							.setEvaluationCriterionPdf(evaluationCriterionPdf);
					organizationRecords
							.setRiskManagementMechanismPdf(riskManagementMechanismPdf);
					organizationRecords
							.setTreatmentMeasurePdf(treatmentMeasurePdf);
					organizationRecords
							.setResearchManagementPrincipalPdf(researchManagementPrincipalPdf);

					// 2016-04-21 10:23:01 xiaoan start
					organizationRecords
							.setResearchManagementPrincipalDuty(researchManagementPrincipalDuty);
					organizationRecords
							.setResearchManagementPrincipalProfessional(researchManagementPrincipalProfessional);
					organizationRecords
							.setResearchManagementPrincipalSpecialty(researchManagementPrincipalSpecialty);
					organizationRecords
							.setResearchManagementPrincipalCertificatePdf(researchManagementPrincipalCertificatePdf);
					organizationRecords
							.setResearchManagementAttorneyDuty(researchManagementAttorneyDuty);
					organizationRecords
							.setResearchManagementAttorneyProfessional(researchManagementAttorneyProfessional);
					organizationRecords
							.setResearchManagementAttorneySpecialty(researchManagementAttorneySpecialty);
					organizationRecords
							.setResearchManagementAttorneyEducation(researchManagementAttorneyEducation);
					organizationRecords
							.setResearchManagementAttorneyLimit(researchManagementAttorneyLimit);
					organizationRecords
							.setResearchManagementAttorneyExperiencePdf(researchManagementAttorneyExperiencePdf);
					organizationRecords
							.setEthicalTrainingPdf(ethicalTrainingPdf);
					organizationRecords.setAcademicPdf(academicPdf);
					organizationRecords
							.setAcademicDirectorName(academicDirectorName);
					organizationRecords
							.setAcademicDirectorDuty(academicDirectorDuty);
					organizationRecords
							.setAcademicDirectorProfessional(academicDirectorProfessional);
					organizationRecords
							.setAcademicDirectorSpecialty(academicDirectorSpecialty);
					organizationRecords
							.setAcademicDirectorUnit(academicDirectorUnit);
					organizationRecords.setEthicalPdf(ethicalPdf);
					organizationRecords
							.setEthicalDirectorName(ethicalDirectorName);
					organizationRecords
							.setEthicalDirectorDuty(ethicalDirectorDuty);
					organizationRecords
							.setEthicalDirectorProfessional(ethicalDirectorProfessional);
					organizationRecords
							.setEthicalDirectorSpecialty(ethicalDirectorSpecialty);
					organizationRecords
							.setEthicalDirectorUnit(ethicalDirectorUnit);
					organizationRecords
							.setPreparationStandardDevice(preparationStandardDevice);
					organizationRecords
							.setPreparationStandardConditionPdf(preparationStandardConditionPdf);
					organizationRecords
							.setStudyQualityManagementDocumentRoutine(studyQualityManagementDocumentRoutine);
					organizationRecords
							.setStudyQualityManagementDocumentSheet(studyQualityManagementDocumentSheet);
					organizationRecords
							.setStudyQualityManagementDocumentElse(studyQualityManagementDocumentElse);
					organizationRecords
							.setAuditSystemEvidencePdf(auditSystemEvidencePdf);
					organizationRecords
							.setAuditSystemInstitutionPdf(auditSystemInstitutionPdf);
					organizationRecords
							.setEvaluationCriterionMonitoringDevice(evaluationCriterionMonitoringDevice);
					organizationRecords
							.setOtherRelevantInformation(otherRelevantInformation);
					// 2016-04-21 10:23:01 xiaoan end

					organizationRecordsService.saveEntity(organizationRecords);

					// 2016-11-20 23:11:44 xiaoan start
					// 药物临床试验机构资格认定证书
					List<OrganizationRecordsCertificate> orcList = organizationRecordsCertificateService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcList.size(); i++) {
						OrganizationRecordsCertificate aOrganizationRecordsCertificate = orcList
								.get(i);
						aOrganizationRecordsCertificate
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCertificateService
								.updateEntity(aOrganizationRecordsCertificate);
					}
					// 机构承担项目情况
					List<OrganizationRecordsAssumeProject> oraList = organizationRecordsAssumeProjectService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oraList.size(); i++) {
						OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = oraList
								.get(i);
						aOrganizationRecordsAssumeProject
								.setOrganizationRecords(organizationRecords);
						organizationRecordsAssumeProjectService
								.updateEntity(aOrganizationRecordsAssumeProject);
					}
					// 内审人员信息
					List<OrganizationRecordsInternalAudit> oriList = organizationRecordsInternalAuditService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oriList.size(); i++) {
						OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = oriList
								.get(i);
						aOrganizationRecordsInternalAudit
								.setOrganizationRecords(organizationRecords);
						organizationRecordsInternalAuditService
								.updateEntity(aOrganizationRecordsInternalAudit);
					}
					// 学术委员会
					List<OrganizationRecordsCommittee> orcoList = organizationRecordsCommitteeService
							.findByPropertys("o.username=? ",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcoList.size(); i++) {
						OrganizationRecordsCommittee aOrganizationRecordsCommittee = orcoList
								.get(i);
						aOrganizationRecordsCommittee
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCommitteeService
								.updateEntity(aOrganizationRecordsCommittee);
					}
					// 2016-11-20 23:11:44 xiaoan end

				}
				super.pringWriterToPage("success");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				super.pringWriterToPage("error");
			}
		}
		return null;

	}

	public String saveOrg() throws Exception {
		// UserInfoView user = (UserInfoView) getSession().getAttribute("user");
		User userS = (User) getSession().getAttribute("user");
		if (userS != null) {
			try {
				Organization organization = organizationService.find(userS
						.getOrganization().getId());

				organization.setOrganType(organType);
				organization.setOrganLevel(organLevel);
				organization.setAddress(address);
				organization.setPostCode(postCode);
				organization.setContactEmail(contactEmail);
				organization.setContactMobile(contactMobile);
				organization.setContactPhone(contactPhone);
				organization.setContactUser(contactUser);
				organization.setResponsiblePerson(responsiblePerson);

				organization.setCreateTime(DateUtils.getDateTime());
				organization.setCreateUser(userS.getName());

				organizationService.updateEntity(organization);

				userS.setOrganization(organization);
				getSession().setAttribute("user", userS);

				List<OrganizationRecords> list = organizationRecordsService
						.findByProperty("organization.id", userS
								.getOrganization().getId());

				if (null != list && list.size() > 0) {
					OrganizationRecords organizationRecords = list.get(0);

					organizationRecords.setOrganization(organization);
					organizationRecords.setStatus(0);

					organizationRecords
							.setMedicalInstitutionsExequaturPdf(medicalInstitutionsExequaturPdf);
					organizationRecords
							.setMedicalInstitutionsExequaturSubject(medicalInstitutionsExequaturSubject);
					organizationRecords
							.setMedicalInstitutionsExequaturStartDate(medicalInstitutionsExequaturStartDate);
					organizationRecords
							.setMedicalInstitutionsExequaturEndDate(medicalInstitutionsExequaturEndDate);
					organizationRecords
							.setMedicalInstitutionsExequaturRegisterNum(medicalInstitutionsExequaturRegisterNum);
					organizationRecords
							.setOrganizationScheme(organizationScheme);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementPrincipalResponsible(researchManagementPrincipalResponsible);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementAttorneyQualifiedPerson(researchManagementAttorneyQualifiedPerson);
					organizationRecords
							.setReceiveTrainingPdf(receiveTrainingPdf);
					// organizationRecords.setAcademicAndEthicalPdf(academicAndEthicalPdf);
					organizationRecords.setWorkingSystemPdf(workingSystemPdf);
					organizationRecords
							.setPreparationStandardPdf(preparationStandardPdf);
					organizationRecords
							.setStudyQualityManagementDocumentPdf(studyQualityManagementDocumentPdf);
					organizationRecords.setAuditSystemPdf(auditSystemPdf);
					organizationRecords
							.setEvaluationCriterionPdf(evaluationCriterionPdf);
					organizationRecords
							.setRiskManagementMechanismPdf(riskManagementMechanismPdf);
					organizationRecords
							.setTreatmentMeasurePdf(treatmentMeasurePdf);
					organizationRecords
							.setResearchManagementPrincipalPdf(researchManagementPrincipalPdf);
					// 清空审核信息
					organizationRecords.setReason(null);

					// 2016-04-21 10:27:19 xiaoan start
					organizationRecords
							.setResearchManagementPrincipalDuty(researchManagementPrincipalDuty);
					organizationRecords
							.setResearchManagementPrincipalProfessional(researchManagementPrincipalProfessional);
					organizationRecords
							.setResearchManagementPrincipalSpecialty(researchManagementPrincipalSpecialty);
					organizationRecords
							.setResearchManagementPrincipalCertificatePdf(researchManagementPrincipalCertificatePdf);
					organizationRecords
							.setResearchManagementAttorneyDuty(researchManagementAttorneyDuty);
					organizationRecords
							.setResearchManagementAttorneyProfessional(researchManagementAttorneyProfessional);
					organizationRecords
							.setResearchManagementAttorneySpecialty(researchManagementAttorneySpecialty);
					organizationRecords
							.setResearchManagementAttorneyEducation(researchManagementAttorneyEducation);
					organizationRecords
							.setResearchManagementAttorneyLimit(researchManagementAttorneyLimit);
					organizationRecords
							.setResearchManagementAttorneyExperiencePdf(researchManagementAttorneyExperiencePdf);
					organizationRecords
							.setEthicalTrainingPdf(ethicalTrainingPdf);
					organizationRecords.setAcademicPdf(academicPdf);
					organizationRecords
							.setAcademicDirectorName(academicDirectorName);
					organizationRecords
							.setAcademicDirectorDuty(academicDirectorDuty);
					organizationRecords
							.setAcademicDirectorProfessional(academicDirectorProfessional);
					organizationRecords
							.setAcademicDirectorSpecialty(academicDirectorSpecialty);
					organizationRecords
							.setAcademicDirectorUnit(academicDirectorUnit);
					organizationRecords.setEthicalPdf(ethicalPdf);
					organizationRecords
							.setEthicalDirectorName(ethicalDirectorName);
					organizationRecords
							.setEthicalDirectorDuty(ethicalDirectorDuty);
					organizationRecords
							.setEthicalDirectorProfessional(ethicalDirectorProfessional);
					organizationRecords
							.setEthicalDirectorSpecialty(ethicalDirectorSpecialty);
					organizationRecords
							.setEthicalDirectorUnit(ethicalDirectorUnit);
					organizationRecords
							.setPreparationStandardDevice(preparationStandardDevice);
					organizationRecords
							.setPreparationStandardConditionPdf(preparationStandardConditionPdf);
					organizationRecords
							.setStudyQualityManagementDocumentRoutine(studyQualityManagementDocumentRoutine);
					organizationRecords
							.setStudyQualityManagementDocumentSheet(studyQualityManagementDocumentSheet);
					organizationRecords
							.setStudyQualityManagementDocumentElse(studyQualityManagementDocumentElse);
					organizationRecords
							.setAuditSystemEvidencePdf(auditSystemEvidencePdf);
					organizationRecords
							.setAuditSystemInstitutionPdf(auditSystemInstitutionPdf);
					organizationRecords
							.setEvaluationCriterionMonitoringDevice(evaluationCriterionMonitoringDevice);
					organizationRecords
							.setOtherRelevantInformation(otherRelevantInformation);
					// 2016-04-21 10:27:19 xiaoan end

					organizationRecordsService
							.updateEntity(organizationRecords);

					// 2016-11-20 23:11:44 xiaoan start
					// 药物临床试验机构资格认定证书
					List<OrganizationRecordsCertificate> orcList = organizationRecordsCertificateService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcList.size(); i++) {
						OrganizationRecordsCertificate aOrganizationRecordsCertificate = orcList
								.get(i);
						aOrganizationRecordsCertificate
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCertificateService
								.updateEntity(aOrganizationRecordsCertificate);
					}
					// 机构承担项目情况
					List<OrganizationRecordsAssumeProject> oraList = organizationRecordsAssumeProjectService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oraList.size(); i++) {
						OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = oraList
								.get(i);
						aOrganizationRecordsAssumeProject
								.setOrganizationRecords(organizationRecords);
						organizationRecordsAssumeProjectService
								.updateEntity(aOrganizationRecordsAssumeProject);
					}
					// 内审人员信息
					List<OrganizationRecordsInternalAudit> oriList = organizationRecordsInternalAuditService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oriList.size(); i++) {
						OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = oriList
								.get(i);
						aOrganizationRecordsInternalAudit
								.setOrganizationRecords(organizationRecords);
						organizationRecordsInternalAuditService
								.updateEntity(aOrganizationRecordsInternalAudit);
					}
					// 学术委员会
					List<OrganizationRecordsCommittee> orcoList = organizationRecordsCommitteeService
							.findByPropertys("o.username=? ",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcoList.size(); i++) {
						OrganizationRecordsCommittee aOrganizationRecordsCommittee = orcoList
								.get(i);
						aOrganizationRecordsCommittee
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCommitteeService
								.updateEntity(aOrganizationRecordsCommittee);
					}
					// 2016-11-20 23:11:44 xiaoan end

				} else {
					OrganizationRecords organizationRecords = new OrganizationRecords();

					organizationRecords.setOrganization(organization);
					organizationRecords.setStatus(0);

					organizationRecords
							.setMedicalInstitutionsExequaturPdf(medicalInstitutionsExequaturPdf);
					organizationRecords
							.setMedicalInstitutionsExequaturSubject(medicalInstitutionsExequaturSubject);
					organizationRecords
							.setMedicalInstitutionsExequaturStartDate(medicalInstitutionsExequaturStartDate);
					organizationRecords
							.setMedicalInstitutionsExequaturEndDate(medicalInstitutionsExequaturEndDate);
					organizationRecords
							.setMedicalInstitutionsExequaturRegisterNum(medicalInstitutionsExequaturRegisterNum);
					organizationRecords
							.setOrganizationScheme(organizationScheme);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementPrincipalResponsible(researchManagementPrincipalResponsible);
					organizationRecords
							.setResearchManagementAttorneyPdf(researchManagementAttorneyPdf);
					organizationRecords
							.setResearchManagementAttorneyQualifiedPerson(researchManagementAttorneyQualifiedPerson);
					organizationRecords
							.setReceiveTrainingPdf(receiveTrainingPdf);
					// organizationRecords.setAcademicAndEthicalPdf(academicAndEthicalPdf);
					organizationRecords.setWorkingSystemPdf(workingSystemPdf);
					organizationRecords
							.setPreparationStandardPdf(preparationStandardPdf);
					organizationRecords
							.setStudyQualityManagementDocumentPdf(studyQualityManagementDocumentPdf);
					organizationRecords.setAuditSystemPdf(auditSystemPdf);
					organizationRecords
							.setEvaluationCriterionPdf(evaluationCriterionPdf);
					organizationRecords
							.setRiskManagementMechanismPdf(riskManagementMechanismPdf);
					organizationRecords
							.setTreatmentMeasurePdf(treatmentMeasurePdf);
					organizationRecords
							.setResearchManagementPrincipalPdf(researchManagementPrincipalPdf);

					// 2016-04-21 10:23:01 xiaoan start
					organizationRecords
							.setResearchManagementPrincipalDuty(researchManagementPrincipalDuty);
					organizationRecords
							.setResearchManagementPrincipalProfessional(researchManagementPrincipalProfessional);
					organizationRecords
							.setResearchManagementPrincipalSpecialty(researchManagementPrincipalSpecialty);
					organizationRecords
							.setResearchManagementPrincipalCertificatePdf(researchManagementPrincipalCertificatePdf);
					organizationRecords
							.setResearchManagementAttorneyDuty(researchManagementAttorneyDuty);
					organizationRecords
							.setResearchManagementAttorneyProfessional(researchManagementAttorneyProfessional);
					organizationRecords
							.setResearchManagementAttorneySpecialty(researchManagementAttorneySpecialty);
					organizationRecords
							.setResearchManagementAttorneyEducation(researchManagementAttorneyEducation);
					organizationRecords
							.setResearchManagementAttorneyLimit(researchManagementAttorneyLimit);
					organizationRecords
							.setResearchManagementAttorneyExperiencePdf(researchManagementAttorneyExperiencePdf);
					organizationRecords
							.setEthicalTrainingPdf(ethicalTrainingPdf);
					organizationRecords.setAcademicPdf(academicPdf);
					organizationRecords
							.setAcademicDirectorName(academicDirectorName);
					organizationRecords
							.setAcademicDirectorDuty(academicDirectorDuty);
					organizationRecords
							.setAcademicDirectorProfessional(academicDirectorProfessional);
					organizationRecords
							.setAcademicDirectorSpecialty(academicDirectorSpecialty);
					organizationRecords
							.setAcademicDirectorUnit(academicDirectorUnit);
					organizationRecords.setEthicalPdf(ethicalPdf);
					organizationRecords
							.setEthicalDirectorName(ethicalDirectorName);
					organizationRecords
							.setEthicalDirectorDuty(ethicalDirectorDuty);
					organizationRecords
							.setEthicalDirectorProfessional(ethicalDirectorProfessional);
					organizationRecords
							.setEthicalDirectorSpecialty(ethicalDirectorSpecialty);
					organizationRecords
							.setEthicalDirectorUnit(ethicalDirectorUnit);
					organizationRecords
							.setPreparationStandardDevice(preparationStandardDevice);
					organizationRecords
							.setPreparationStandardConditionPdf(preparationStandardConditionPdf);
					organizationRecords
							.setStudyQualityManagementDocumentRoutine(studyQualityManagementDocumentRoutine);
					organizationRecords
							.setStudyQualityManagementDocumentSheet(studyQualityManagementDocumentSheet);
					organizationRecords
							.setStudyQualityManagementDocumentElse(studyQualityManagementDocumentElse);
					organizationRecords
							.setAuditSystemEvidencePdf(auditSystemEvidencePdf);
					organizationRecords
							.setAuditSystemInstitutionPdf(auditSystemInstitutionPdf);
					organizationRecords
							.setEvaluationCriterionMonitoringDevice(evaluationCriterionMonitoringDevice);
					organizationRecords
							.setOtherRelevantInformation(otherRelevantInformation);
					// 2016-04-21 10:23:01 xiaoan end

					organizationRecordsService.saveEntity(organizationRecords);

					// 2016-11-20 23:11:44 xiaoan start
					// 药物临床试验机构资格认定证书
					List<OrganizationRecordsCertificate> orcList = organizationRecordsCertificateService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcList.size(); i++) {
						OrganizationRecordsCertificate aOrganizationRecordsCertificate = orcList
								.get(i);
						aOrganizationRecordsCertificate
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCertificateService
								.updateEntity(aOrganizationRecordsCertificate);
					}
					// 机构承担项目情况
					List<OrganizationRecordsAssumeProject> oraList = organizationRecordsAssumeProjectService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oraList.size(); i++) {
						OrganizationRecordsAssumeProject aOrganizationRecordsAssumeProject = oraList
								.get(i);
						aOrganizationRecordsAssumeProject
								.setOrganizationRecords(organizationRecords);
						organizationRecordsAssumeProjectService
								.updateEntity(aOrganizationRecordsAssumeProject);
					}
					// 内审人员信息
					List<OrganizationRecordsInternalAudit> oriList = organizationRecordsInternalAuditService
							.findByPropertys("o.username=?",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < oriList.size(); i++) {
						OrganizationRecordsInternalAudit aOrganizationRecordsInternalAudit = oriList
								.get(i);
						aOrganizationRecordsInternalAudit
								.setOrganizationRecords(organizationRecords);
						organizationRecordsInternalAuditService
								.updateEntity(aOrganizationRecordsInternalAudit);
					}
					// 学术委员会
					List<OrganizationRecordsCommittee> orcoList = organizationRecordsCommitteeService
							.findByPropertys("o.username=? ",
									new Object[] { userS.getUsername() });
					for (int i = 0; i < orcoList.size(); i++) {
						OrganizationRecordsCommittee aOrganizationRecordsCommittee = orcoList
								.get(i);
						aOrganizationRecordsCommittee
								.setOrganizationRecords(organizationRecords);
						organizationRecordsCommitteeService
								.updateEntity(aOrganizationRecordsCommittee);
					}
					// 2016-11-20 23:11:44 xiaoan end

				}
				super.pringWriterToPage("success");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				super.pringWriterToPage("error");
			}
		}
		return null;
	}

	public String saveOrgWeiHu() throws Exception {

		User userS = (User) getSession().getAttribute("user");
		if (userS != null) {
			try {

				Organization organization = userS.getOrganization();
				organization.setName(name);
				// Province provinceObj = provinceService.find(province);
				// organization.setProvince(provinceObj);// 省份编号

				organization.setOrganType(organType);
				// organization.setOrganCode(organCode);
				organization.setOrganLevel(organLevel);
				organization.setAddress(address);
				organization.setPostCode(postCode);
				organization.setContactEmail(contactEmail);
				organization.setContactMobile(contactMobile);
				organization.setContactPhone(contactPhone);
				organization.setContactUser(contactUser);
				organization.setResponsiblePerson(responsiblePerson);

				organization.setCreateTime(DateUtils.getDateTime());
				organization.setCreateUser(userS.getName());

				// 2016-06-07 15:36:22
				organization
						.setInstitutionEthicsCommitteeConstitution(institutionEthicsCommitteeConstitution);
				organization
						.setInstitutionEthicsCommitteeName(institutionEthicsCommitteeName);
				organization
						.setInstitutionEthicsCommitteePersonnel(institutionEthicsCommitteePersonnel);
				organization
						.setInstitutionEthicsCommitteeProgram(institutionEthicsCommitteeProgram);

				organizationService.updateEntity(organization);

				userS.setOrganization(organization);
				getSession().setAttribute("user", userS);
				super.pringWriterToPage("success");

			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				super.pringWriterToPage("error");
			}
		}
		return null;
	}

	public String checkuser() throws Exception {
		try {
			List<User> list = userService.findByPropertys("o.username=?",
					new Object[] { param });
			if (list.size() > 0) {
				super.pringWriterToPage("此用户名已经重复");
			} else {
				super.pringWriterToPage("y");
			}
		} catch (Exception e) {
			e.printStackTrace();
			// super.pringWriterToPage("n");
		}
		return null;
	}

	public String checkOrgcode() throws Exception {
		try {
			if (ValidateUtils.isValidEntpCode(param)) {
				List<Organization> list = organizationService.findByPropertys(
						"o.organCode=?", new Object[] { param });
				if (list.size() > 0) {
					super.pringWriterToPage("组织机构代码已存在！");
				} else {
					super.pringWriterToPage("y");
				}
			} else {
				super.pringWriterToPage("组织机构格式错误！");
			}
		} catch (Exception e) {
			e.printStackTrace();
			// super.pringWriterToPage("n");
		}
		return null;
	}

	public String checkuserlogin() throws Exception {
		User userS = (User) getSession().getAttribute("user");
		if (null != userS) {
			try {
				List<User> list = userService.findByPropertys(
						"o.username=? and o.username!=?", new Object[] { param,
								userS.getUsername() });
				if (list.size() > 0) {
					super.pringWriterToPage("此用户名已经重复");
				} else {
					super.pringWriterToPage("y");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String checkOrgcodelogin() throws Exception {
		User userS = (User) getSession().getAttribute("user");
		if (null != userS) {
			try {
				List<Organization> list = organizationService
						.findByPropertys(
								"o.organCode=? and o.organCode!=?",
								new Object[] { param,
										userS.getOrganization().getOrganCode() });
				if (list.size() > 0) {
					super.pringWriterToPage("此组织机构编码已经重复");
				} else {
					super.pringWriterToPage("y");
				}
			} catch (Exception e) {
				e.printStackTrace();
				// super.pringWriterToPage("n");
			}
		}
		return null;
	}

	public String saveOrgUser() throws Exception {
		try {
			Organization organization = new Organization();
			organization.setName(name);
			Province provinceObj = provinceService.find(province);
			organization.setProvince(provinceObj);// 省份编号
			organization.setOrganType(organType);
			if (!"其他".equals(organType)) {
				organization.setOrganLevel(organLevel);
			}
			organization.setOrganCode(organCode);
			organization.setAddress(address);
			organization.setPostCode(postCode);
			organization.setContactEmail(contactEmail);
			organization.setContactMobile(contactMobile);
			organization.setContactPhone(contactPhone);
			organization.setContactUser(contactUser);
			organization.setStatus(0);
			organization.setResponsiblePerson(responsiblePerson);
			organization.setCreateTime(DateUtils.getDateTime());
			organization.setCreateUser(username);
			// 2016-12-10 11:12:12 xiaoan
			organization.setIsInvolvedPerson(isInvolvedPerson);
			organization.setIsNationalTwoCommittees(isNationalTwoCommittees);

			// 2016-06-07 15:36:22
			organization
					.setInstitutionEthicsCommitteeConstitution(institutionEthicsCommitteeConstitution);
			organization
					.setInstitutionEthicsCommitteeName(institutionEthicsCommitteeName);
			organization
					.setInstitutionEthicsCommitteePersonnel(institutionEthicsCommitteePersonnel);
			organization
					.setInstitutionEthicsCommitteeProgram(institutionEthicsCommitteeProgram);
			organization.setIsApprovalStemCellsInstitutions("0");
			organizationService.saveEntity(organization);

			User user = new User();
			user.setUsername(username);
			user.setName(truename);
			user.setPassword(password);
			user.setRoleType(2);
			user.setStatus(0);
			user.setProvince(provinceObj);
			user.setOrganization(organization);
			userService.saveEntity(user);

			return "org_regsucess";
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			super.pringWriterToPage("error");
		}
		return null;
	}

	public String saveloginUser() throws Exception {

		User userS = (User) getSession().getAttribute("user");
		if (null != userS) {
			try {
				Organization organization = userS.getOrganization();
				organization.setName(name);
				Province provinceObj = provinceService.find(province);
				organization.setProvince(provinceObj);// 省份编号

				organization.setOrganType(organType);
				// organization.setOrganCode(organCode);
				organization.setOrganLevel(organLevel);
				organization.setAddress(address);
				organization.setPostCode(postCode);
				organization.setContactEmail(contactEmail);
				organization.setContactMobile(contactMobile);
				organization.setContactPhone(contactPhone);
				organization.setContactUser(contactUser);
				organization.setResponsiblePerson(responsiblePerson);

				organization.setCreateTime(DateUtils.getDateTime());
				organization.setCreateUser(userS.getName());

				organizationService.updateEntity(organization);

				userS.setUsername(username);
				userS.setName(truename);
				userS.setPassword(password);
				userS.setStatus(0);
				userS.setReason("");
				userS.setOrganization(organization);

				userService.updateEntity(userS);

				return "org_regsucess";
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				super.pringWriterToPage("error");
			}
		}
		return null;
	}

	public String saveOrgReason() throws Exception {
		if (id != null && id.length() > 0) {
			try {

				List<OrganizationRecords> list = organizationRecordsService
						.findByProperty("organization.id", Integer.parseInt(id));
				OrganizationRecords organizationRecords = list.get(0);

				organizationRecords.setStatus(status);
				if (status == 1) {
					// 设置注册号
					String regNumber = ""
							+ DateUtils.getDateNoStyle().substring(0, 8) + "-";
					LinkedHashMap<String, String> mp = new LinkedHashMap<String, String>();
					mp.put("regNumber", "desc");
					List<OrganizationRecords> orList = organizationRecordsService
							.findByPropertys(
									" o.status=? and o.regNumber like ? ",
									new Object[] { 1, regNumber + "%" }, mp);
					if (orList.size() > 0) {
						regNumber = regNumber
								+ (Integer.parseInt(orList.get(0)
										.getRegNumber().split("-")[1]) + 1);
					} else {
						regNumber = regNumber + "1001";
					}
					organizationRecords.setRegNumber(regNumber); // CMR-20150308-1006
				}
				organizationRecords.setReason(reason);
				organizationRecords
						.setIsSubmitPaperyMaterial(isSubmitPaperyMaterial);
				organizationRecordsService.updateEntity(organizationRecords);

				super.pringWriterToPage("success");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				super.pringWriterToPage("error");
			}
		}
		return null;
	}

	public String saveOrgPass() throws Exception {
		if (id != null && id.length() > 0) {
			try {
				List<OrganizationRecords> list = organizationRecordsService
						.findByProperty("organization.id", Integer.parseInt(id));
				OrganizationRecords organizationRecords = list.get(0);

				// 设置注册号
				String regNumber = ""
						+ DateUtils.getDateNoStyle().substring(0, 8) + "-";
				LinkedHashMap<String, String> mp = new LinkedHashMap<String, String>();
				mp.put("regNumber", "desc");
				List<OrganizationRecords> orList = organizationRecordsService
						.findByPropertys(" o.status=? and o.regNumber like ? ",
								new Object[] { 1, regNumber + "%" }, mp);
				if (orList.size() > 0) {
					regNumber = regNumber
							+ (Integer.parseInt(list.get(0).getRegNumber()
									.split("-")[2]) + 1);
				} else {
					regNumber = regNumber + "1001";
				}
				organizationRecords.setRegNumber(regNumber); // CMR-20150308-1006

				organizationRecords.setStatus(1);
				organizationRecords.setReason("");
				organizationRecordsService.updateEntity(organizationRecords);

				super.pringWriterToPage("success");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				super.pringWriterToPage("error");
			}
		}
		return null;
	}

	public String getProvinceList() throws Exception {

		List<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
		List<Object[]> orglist = provinceService.findBySQL("SELECT province_code as province,COUNT(province_code) as count FROM [dbo].[work_organization] as org LEFT JOIN dbo.work_organization_records as orgrecode on org.id=orgrecode.organization_id where orgrecode.status=1 GROUP BY province_code");

		Map<Object, Object> provMap = new HashMap<Object, Object>();
		if (null != orglist && orglist.size() > 0) {
			for (Object[] numObj : orglist) {
				provMap.put(numObj[0], numObj[1]);
			}
		}

		List<Province> provlist = provinceService.findEntityList();
		for (Province province : provlist) {
			Map<Object, Object> m = new HashMap<Object, Object>();
			m.put("name", province.getName());
			m.put("code", province.getCode());
			if (provMap.containsKey(province.getCode())) {
				m.put("num", provMap.get(province.getCode()));
			} else {
				m.put("num", "0");
			}
			list.add(m);
		}
		super.pringWriterToPage(JsonUtil.formatToJson(list));
		return null;
	}

	
	/**
	 * @author zf
	 * 2017年2月27日23:03:24
	 */
	public String getProvinceExamineList() throws Exception {
		User userS = (User) getSession().getAttribute("user");
		List<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
		List<Object[]> orglist = provinceService.findBySQL("SELECT province_code as province,COUNT(province_code) as count FROM [dbo].[work_organization] as org LEFT JOIN dbo.work_organization_records as orgrecode on org.id=orgrecode.organization_id where orgrecode.status=0 GROUP BY province_code");

		Map<Object, Object> provMap = new HashMap<Object, Object>();
		if (null != orglist && orglist.size() > 0) {
			for (Object[] numObj : orglist) {
				if(numObj[0].equals(userS.getProvince().getCode())){
					provMap.put(numObj[0], numObj[1]);
				}
			}
		}

		List<Province> provlist = provinceService.findEntityList();
		for (Province province : provlist) {
			Map<Object, Object> m = new HashMap<Object, Object>();
			if (provMap.containsKey(province.getCode())) {
				m.put("name", province.getName());
				m.put("code", province.getCode());
				m.put("num", provMap.get(province.getCode()));
				list.add(m);
				break;
			}
		}
		super.pringWriterToPage(JsonUtil.formatToJson(list));
		return null;
	}
	
	
	
	
	/**
	 * @throws
	 * @author ninemax
	 */
	public String getEthicsProvinceList() throws Exception {

		List<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
		List<Object[]> orglist = provinceService
				.findBySQL("SELECT province_code as province,COUNT(province_code) as count FROM [dbo].[work_organization] as org LEFT JOIN dbo.work_organization_records as orgrecode on org.id=orgrecode.organization_id where orgrecode.status=1 GROUP BY province_code");

		Map<Object, Object> provMap = new HashMap<Object, Object>();
		if (null != orglist && orglist.size() > 0) {
			for (Object[] numObj : orglist) {
				provMap.put(numObj[0], numObj[1]);
			}
		}

		List<Province> provlist = provinceService.findEntityList();
		for (Province province : provlist) {
			Map<Object, Object> m = new HashMap<Object, Object>();
			m.put("name", province.getName());
			m.put("code", province.getCode());
			if (provMap.containsKey(province.getCode())) {
				m.put("num", provMap.get(province.getCode()));
			} else {
				m.put("num", "0");
			}
			list.add(m);
		}
		super.pringWriterToPage(JsonUtil.formatToJson(list));
		return null;
	}
	
	/**     */
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public OrganizationService getOrganizationService() {
		return organizationService;
	}

	public void setOrganizationService(OrganizationService organizationService) {
		this.organizationService = organizationService;
	}

	public OrganizationRecordsService getOrganizationRecordsService() {
		return organizationRecordsService;
	}

	public void setOrganizationRecordsService(
			OrganizationRecordsService organizationRecordsService) {
		this.organizationRecordsService = organizationRecordsService;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(String pageIndex) {
		this.pageIndex = pageIndex;
	}

	public String getPageShowCount() {
		return pageShowCount;
	}

	public void setPageShowCount(String pageShowCount) {
		this.pageShowCount = pageShowCount;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getOrganType() {
		return organType;
	}

	public void setOrganType(String organType) {
		this.organType = organType;
	}

	public String getOrganLevel() {
		return organLevel;
	}

	public void setOrganLevel(String organLevel) {
		this.organLevel = organLevel;
	}

	public String getOrganCode() {
		return organCode;
	}

	public void setOrganCode(String organCode) {
		this.organCode = organCode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPostCode() {
		return postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	public String getContactUser() {
		return contactUser;
	}

	public void setContactUser(String contactUser) {
		this.contactUser = contactUser;
	}

	public String getContactPhone() {
		return contactPhone;
	}

	public void setContactPhone(String contactPhone) {
		this.contactPhone = contactPhone;
	}

	public String getContactMobile() {
		return contactMobile;
	}

	public void setContactMobile(String contactMobile) {
		this.contactMobile = contactMobile;
	}

	public String getContactEmail() {
		return contactEmail;
	}

	public void setContactEmail(String contactEmail) {
		this.contactEmail = contactEmail;
	}

	public String getCrTime() {
		return crTime;
	}

	public void setCrTime(String crTime) {
		this.crTime = crTime;
	}

	public String getCrUser() {
		return crUser;
	}

	public void setCrUser(String crUser) {
		this.crUser = crUser;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getOrganizationScheme() {
		return organizationScheme;
	}

	public void setOrganizationScheme(String organizationScheme) {
		this.organizationScheme = organizationScheme;
	}

	public int getDefaultPageShowCount() {
		return defaultPageShowCount;
	}

	public void setDefaultPageShowCount(int defaultPageShowCount) {
		this.defaultPageShowCount = defaultPageShowCount;
	}

	public ProvinceService getProvinceService() {
		return provinceService;
	}

	public void setProvinceService(ProvinceService provinceService) {
		this.provinceService = provinceService;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getParam() {
		return param;
	}

	public void setParam(String param) {
		this.param = param;
	}

	public String getTruename() {
		return truename;
	}

	public void setTruename(String truename) {
		this.truename = truename;
	}

	public String getResponsiblePerson() {
		return responsiblePerson;
	}

	public void setResponsiblePerson(String responsiblePerson) {
		this.responsiblePerson = responsiblePerson;
	}

	public String getIsSubmitPaperyMaterial() {
		return isSubmitPaperyMaterial;
	}

	public void setIsSubmitPaperyMaterial(String isSubmitPaperyMaterial) {
		this.isSubmitPaperyMaterial = isSubmitPaperyMaterial;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getSearchText() {
		return searchText;
	}

	public void setSearchText(String searchText) {
		this.searchText = searchText;
	}

	public String getMedicalInstitutionsExequaturPdf() {
		return medicalInstitutionsExequaturPdf;
	}

	public void setMedicalInstitutionsExequaturPdf(
			String medicalInstitutionsExequaturPdf) {
		this.medicalInstitutionsExequaturPdf = medicalInstitutionsExequaturPdf;
	}

	public String getMedicalInstitutionsExequaturSubject() {
		return medicalInstitutionsExequaturSubject;
	}

	public void setMedicalInstitutionsExequaturSubject(
			String medicalInstitutionsExequaturSubject) {
		this.medicalInstitutionsExequaturSubject = medicalInstitutionsExequaturSubject;
	}

	public String getMedicalInstitutionsExequaturStartDate() {
		return medicalInstitutionsExequaturStartDate;
	}

	public void setMedicalInstitutionsExequaturStartDate(
			String medicalInstitutionsExequaturStartDate) {
		this.medicalInstitutionsExequaturStartDate = medicalInstitutionsExequaturStartDate;
	}

	public String getMedicalInstitutionsExequaturEndDate() {
		return medicalInstitutionsExequaturEndDate;
	}

	public void setMedicalInstitutionsExequaturEndDate(
			String medicalInstitutionsExequaturEndDate) {
		this.medicalInstitutionsExequaturEndDate = medicalInstitutionsExequaturEndDate;
	}

	public String getMedicalInstitutionsExequaturRegisterNum() {
		return medicalInstitutionsExequaturRegisterNum;
	}

	public void setMedicalInstitutionsExequaturRegisterNum(
			String medicalInstitutionsExequaturRegisterNum) {
		this.medicalInstitutionsExequaturRegisterNum = medicalInstitutionsExequaturRegisterNum;
	}

	public String getResearchManagementPrincipalPdf() {
		return researchManagementPrincipalPdf;
	}

	public void setResearchManagementPrincipalPdf(
			String researchManagementPrincipalPdf) {
		this.researchManagementPrincipalPdf = researchManagementPrincipalPdf;
	}

	public String getResearchManagementPrincipalResponsible() {
		return researchManagementPrincipalResponsible;
	}

	public void setResearchManagementPrincipalResponsible(
			String researchManagementPrincipalResponsible) {
		this.researchManagementPrincipalResponsible = researchManagementPrincipalResponsible;
	}

	public String getResearchManagementAttorneyPdf() {
		return researchManagementAttorneyPdf;
	}

	public void setResearchManagementAttorneyPdf(
			String researchManagementAttorneyPdf) {
		this.researchManagementAttorneyPdf = researchManagementAttorneyPdf;
	}

	public String getResearchManagementAttorneyQualifiedPerson() {
		return researchManagementAttorneyQualifiedPerson;
	}

	public void setResearchManagementAttorneyQualifiedPerson(
			String researchManagementAttorneyQualifiedPerson) {
		this.researchManagementAttorneyQualifiedPerson = researchManagementAttorneyQualifiedPerson;
	}

	public String getReceiveTrainingPdf() {
		return receiveTrainingPdf;
	}

	public void setReceiveTrainingPdf(String receiveTrainingPdf) {
		this.receiveTrainingPdf = receiveTrainingPdf;
	}

	public String getAcademicAndEthicalPdf() {
		return academicAndEthicalPdf;
	}

	public void setAcademicAndEthicalPdf(String academicAndEthicalPdf) {
		this.academicAndEthicalPdf = academicAndEthicalPdf;
	}

	public String getWorkingSystemPdf() {
		return workingSystemPdf;
	}

	public void setWorkingSystemPdf(String workingSystemPdf) {
		this.workingSystemPdf = workingSystemPdf;
	}

	public String getPreparationStandardPdf() {
		return preparationStandardPdf;
	}

	public void setPreparationStandardPdf(String preparationStandardPdf) {
		this.preparationStandardPdf = preparationStandardPdf;
	}

	public String getStudyQualityManagementDocumentPdf() {
		return studyQualityManagementDocumentPdf;
	}

	public void setStudyQualityManagementDocumentPdf(
			String studyQualityManagementDocumentPdf) {
		this.studyQualityManagementDocumentPdf = studyQualityManagementDocumentPdf;
	}

	public String getAuditSystemPdf() {
		return auditSystemPdf;
	}

	public void setAuditSystemPdf(String auditSystemPdf) {
		this.auditSystemPdf = auditSystemPdf;
	}

	public String getEvaluationCriterionPdf() {
		return evaluationCriterionPdf;
	}

	public void setEvaluationCriterionPdf(String evaluationCriterionPdf) {
		this.evaluationCriterionPdf = evaluationCriterionPdf;
	}

	public String getRiskManagementMechanismPdf() {
		return riskManagementMechanismPdf;
	}

	public void setRiskManagementMechanismPdf(String riskManagementMechanismPdf) {
		this.riskManagementMechanismPdf = riskManagementMechanismPdf;
	}

	public String getTreatmentMeasurePdf() {
		return treatmentMeasurePdf;
	}

	public void setTreatmentMeasurePdf(String treatmentMeasurePdf) {
		this.treatmentMeasurePdf = treatmentMeasurePdf;
	}

	public String getPdf() {
		return pdf;
	}

	public void setPdf(String pdf) {
		this.pdf = pdf;
	}

	public String getCertNumber() {
		return certNumber;
	}

	public void setCertNumber(String certNumber) {
		this.certNumber = certNumber;
	}

	public String getAffirmationProfession() {
		return affirmationProfession;
	}

	public void setAffirmationProfession(String affirmationProfession) {
		this.affirmationProfession = affirmationProfession;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getProjectType() {
		return projectType;
	}

	public void setProjectType(String projectType) {
		this.projectType = projectType;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getProjectNumber() {
		return projectNumber;
	}

	public void setProjectNumber(String projectNumber) {
		this.projectNumber = projectNumber;
	}

	public String getPrincipal() {
		return principal;
	}

	public void setPrincipal(String principal) {
		this.principal = principal;
	}

	public String getExpenditure() {
		return expenditure;
	}

	public void setExpenditure(String expenditure) {
		this.expenditure = expenditure;
	}

	public String getLeaderUnit() {
		return leaderUnit;
	}

	public void setLeaderUnit(String leaderUnit) {
		this.leaderUnit = leaderUnit;
	}

	public String getParticipationUnit() {
		return participationUnit;
	}

	public void setParticipationUnit(String participationUnit) {
		this.participationUnit = participationUnit;
	}

	public String getMemberName() {
		return memberName;
	}

	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}

	public String getDuty() {
		return duty;
	}

	public void setDuty(String duty) {
		this.duty = duty;
	}

	public String getProfessional() {
		return professional;
	}

	public void setProfessional(String professional) {
		this.professional = professional;
	}

	public String getSpecialty() {
		return specialty;
	}

	public void setSpecialty(String specialty) {
		this.specialty = specialty;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public Integer getMemberType() {
		return memberType;
	}

	public void setMemberType(Integer memberType) {
		this.memberType = memberType;
	}

	public Integer getCommitteeType() {
		return committeeType;
	}

	public void setCommitteeType(Integer committeeType) {
		this.committeeType = committeeType;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getResearchManagementPrincipalDuty() {
		return researchManagementPrincipalDuty;
	}

	public void setResearchManagementPrincipalDuty(
			String researchManagementPrincipalDuty) {
		this.researchManagementPrincipalDuty = researchManagementPrincipalDuty;
	}

	public String getResearchManagementPrincipalProfessional() {
		return researchManagementPrincipalProfessional;
	}

	public void setResearchManagementPrincipalProfessional(
			String researchManagementPrincipalProfessional) {
		this.researchManagementPrincipalProfessional = researchManagementPrincipalProfessional;
	}

	public String getResearchManagementPrincipalSpecialty() {
		return researchManagementPrincipalSpecialty;
	}

	public void setResearchManagementPrincipalSpecialty(
			String researchManagementPrincipalSpecialty) {
		this.researchManagementPrincipalSpecialty = researchManagementPrincipalSpecialty;
	}

	public String getResearchManagementPrincipalCertificatePdf() {
		return researchManagementPrincipalCertificatePdf;
	}

	public void setResearchManagementPrincipalCertificatePdf(
			String researchManagementPrincipalCertificatePdf) {
		this.researchManagementPrincipalCertificatePdf = researchManagementPrincipalCertificatePdf;
	}

	public String getResearchManagementAttorneyDuty() {
		return researchManagementAttorneyDuty;
	}

	public void setResearchManagementAttorneyDuty(
			String researchManagementAttorneyDuty) {
		this.researchManagementAttorneyDuty = researchManagementAttorneyDuty;
	}

	public String getResearchManagementAttorneyProfessional() {
		return researchManagementAttorneyProfessional;
	}

	public void setResearchManagementAttorneyProfessional(
			String researchManagementAttorneyProfessional) {
		this.researchManagementAttorneyProfessional = researchManagementAttorneyProfessional;
	}

	public String getResearchManagementAttorneySpecialty() {
		return researchManagementAttorneySpecialty;
	}

	public void setResearchManagementAttorneySpecialty(
			String researchManagementAttorneySpecialty) {
		this.researchManagementAttorneySpecialty = researchManagementAttorneySpecialty;
	}

	public String getResearchManagementAttorneyEducation() {
		return researchManagementAttorneyEducation;
	}

	public void setResearchManagementAttorneyEducation(
			String researchManagementAttorneyEducation) {
		this.researchManagementAttorneyEducation = researchManagementAttorneyEducation;
	}

	public String getResearchManagementAttorneyLimit() {
		return researchManagementAttorneyLimit;
	}

	public void setResearchManagementAttorneyLimit(
			String researchManagementAttorneyLimit) {
		this.researchManagementAttorneyLimit = researchManagementAttorneyLimit;
	}

	public String getResearchManagementAttorneyExperiencePdf() {
		return researchManagementAttorneyExperiencePdf;
	}

	public void setResearchManagementAttorneyExperiencePdf(
			String researchManagementAttorneyExperiencePdf) {
		this.researchManagementAttorneyExperiencePdf = researchManagementAttorneyExperiencePdf;
	}

	public String getEthicalTrainingPdf() {
		return ethicalTrainingPdf;
	}

	public void setEthicalTrainingPdf(String ethicalTrainingPdf) {
		this.ethicalTrainingPdf = ethicalTrainingPdf;
	}

	public String getAcademicPdf() {
		return academicPdf;
	}

	public void setAcademicPdf(String academicPdf) {
		this.academicPdf = academicPdf;
	}

	public String getAcademicDirectorName() {
		return academicDirectorName;
	}

	public void setAcademicDirectorName(String academicDirectorName) {
		this.academicDirectorName = academicDirectorName;
	}

	public String getAcademicDirectorDuty() {
		return academicDirectorDuty;
	}

	public void setAcademicDirectorDuty(String academicDirectorDuty) {
		this.academicDirectorDuty = academicDirectorDuty;
	}

	public String getAcademicDirectorProfessional() {
		return academicDirectorProfessional;
	}

	public void setAcademicDirectorProfessional(
			String academicDirectorProfessional) {
		this.academicDirectorProfessional = academicDirectorProfessional;
	}

	public String getAcademicDirectorSpecialty() {
		return academicDirectorSpecialty;
	}

	public void setAcademicDirectorSpecialty(String academicDirectorSpecialty) {
		this.academicDirectorSpecialty = academicDirectorSpecialty;
	}

	public String getAcademicDirectorUnit() {
		return academicDirectorUnit;
	}

	public void setAcademicDirectorUnit(String academicDirectorUnit) {
		this.academicDirectorUnit = academicDirectorUnit;
	}

	public String getEthicalPdf() {
		return ethicalPdf;
	}

	public void setEthicalPdf(String ethicalPdf) {
		this.ethicalPdf = ethicalPdf;
	}

	public String getEthicalDirectorName() {
		return ethicalDirectorName;
	}

	public void setEthicalDirectorName(String ethicalDirectorName) {
		this.ethicalDirectorName = ethicalDirectorName;
	}

	public String getEthicalDirectorDuty() {
		return ethicalDirectorDuty;
	}

	public void setEthicalDirectorDuty(String ethicalDirectorDuty) {
		this.ethicalDirectorDuty = ethicalDirectorDuty;
	}

	public String getEthicalDirectorProfessional() {
		return ethicalDirectorProfessional;
	}

	public void setEthicalDirectorProfessional(
			String ethicalDirectorProfessional) {
		this.ethicalDirectorProfessional = ethicalDirectorProfessional;
	}

	public String getEthicalDirectorSpecialty() {
		return ethicalDirectorSpecialty;
	}

	public void setEthicalDirectorSpecialty(String ethicalDirectorSpecialty) {
		this.ethicalDirectorSpecialty = ethicalDirectorSpecialty;
	}

	public String getEthicalDirectorUnit() {
		return ethicalDirectorUnit;
	}

	public void setEthicalDirectorUnit(String ethicalDirectorUnit) {
		this.ethicalDirectorUnit = ethicalDirectorUnit;
	}

	public String getPreparationStandardConditionPdf() {
		return preparationStandardConditionPdf;
	}

	public void setPreparationStandardConditionPdf(
			String preparationStandardConditionPdf) {
		this.preparationStandardConditionPdf = preparationStandardConditionPdf;
	}

	public String getStudyQualityManagementDocumentRoutine() {
		return studyQualityManagementDocumentRoutine;
	}

	public void setStudyQualityManagementDocumentRoutine(
			String studyQualityManagementDocumentRoutine) {
		this.studyQualityManagementDocumentRoutine = studyQualityManagementDocumentRoutine;
	}

	public String getStudyQualityManagementDocumentSheet() {
		return studyQualityManagementDocumentSheet;
	}

	public void setStudyQualityManagementDocumentSheet(
			String studyQualityManagementDocumentSheet) {
		this.studyQualityManagementDocumentSheet = studyQualityManagementDocumentSheet;
	}

	public String getStudyQualityManagementDocumentElse() {
		return studyQualityManagementDocumentElse;
	}

	public void setStudyQualityManagementDocumentElse(
			String studyQualityManagementDocumentElse) {
		this.studyQualityManagementDocumentElse = studyQualityManagementDocumentElse;
	}

	public String getAuditSystemEvidencePdf() {
		return auditSystemEvidencePdf;
	}

	public void setAuditSystemEvidencePdf(String auditSystemEvidencePdf) {
		this.auditSystemEvidencePdf = auditSystemEvidencePdf;
	}

	public String getAuditSystemInstitutionPdf() {
		return auditSystemInstitutionPdf;
	}

	public void setAuditSystemInstitutionPdf(String auditSystemInstitutionPdf) {
		this.auditSystemInstitutionPdf = auditSystemInstitutionPdf;
	}

	public String getOtherRelevantInformation() {
		return otherRelevantInformation;
	}

	public void setOtherRelevantInformation(String otherRelevantInformation) {
		this.otherRelevantInformation = otherRelevantInformation;
	}

	public String getMWebAppDir() {
		return mWebAppDir;
	}

	public void setMWebAppDir(String webAppDir) {
		mWebAppDir = webAppDir;
	}

	public File getMGeneratedDir() {
		return mGeneratedDir;
	}

	public void setMGeneratedDir(File generatedDir) {
		mGeneratedDir = generatedDir;
	}

	public String getPreparationStandardDevice() {
		return preparationStandardDevice;
	}

	public void setPreparationStandardDevice(String preparationStandardDevice) {
		this.preparationStandardDevice = preparationStandardDevice;
	}

	public String getEvaluationCriterionMonitoringDevice() {
		return evaluationCriterionMonitoringDevice;
	}

	public void setEvaluationCriterionMonitoringDevice(
			String evaluationCriterionMonitoringDevice) {
		this.evaluationCriterionMonitoringDevice = evaluationCriterionMonitoringDevice;
	}

	public String getInstitutionEthicsCommitteeName() {
		return institutionEthicsCommitteeName;
	}

	public void setInstitutionEthicsCommitteeName(
			String institutionEthicsCommitteeName) {
		this.institutionEthicsCommitteeName = institutionEthicsCommitteeName;
	}

	public String getInstitutionEthicsCommitteePersonnel() {
		return institutionEthicsCommitteePersonnel;
	}

	public void setInstitutionEthicsCommitteePersonnel(
			String institutionEthicsCommitteePersonnel) {
		this.institutionEthicsCommitteePersonnel = institutionEthicsCommitteePersonnel;
	}

	public String getInstitutionEthicsCommitteeConstitution() {
		return institutionEthicsCommitteeConstitution;
	}

	public void setInstitutionEthicsCommitteeConstitution(
			String institutionEthicsCommitteeConstitution) {
		this.institutionEthicsCommitteeConstitution = institutionEthicsCommitteeConstitution;
	}

	public String getInstitutionEthicsCommitteeProgram() {
		return institutionEthicsCommitteeProgram;
	}

	public void setInstitutionEthicsCommitteeProgram(
			String institutionEthicsCommitteeProgram) {
		this.institutionEthicsCommitteeProgram = institutionEthicsCommitteeProgram;
	}

	public String getIsNationalTwoCommittees() {
		return isNationalTwoCommittees;
	}

	public void setIsNationalTwoCommittees(String isNationalTwoCommittees) {
		this.isNationalTwoCommittees = isNationalTwoCommittees;
	}

	public String getIsInvolvedPerson() {
		return isInvolvedPerson;
	}

	public void setIsInvolvedPerson(String isInvolvedPerson) {
		this.isInvolvedPerson = isInvolvedPerson;
	}

}
